package com.order.itemcategoryproject.service.lmpl;

import com.order.itemcategoryproject.mapper.DBlOrderDtOnlineMapper;
import com.order.itemcategoryproject.pojo.VO.dBlOrderDtOnlineVo;
import com.order.itemcategoryproject.pojo.dBlOrderDtOnline;
import com.order.itemcategoryproject.service.DBlOrderDtOnlineService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DBlOrderDtOnlineServicelmpl implements DBlOrderDtOnlineService {


    @Autowired
    private DBlOrderDtOnlineMapper detailMapper;


    /**
     * 添加商品详情信息
     *
     * @param detail
     * @return
     */
    @Override
    public int insertOrderDetailInfo(dBlOrderDtOnline detail) {
        return detailMapper.insertOrderDetailInfo(detail);
    }

    /**
     * 批量添加订单明细信息
     * 这是导入进来的明细信息
     *
     * @param details
     */
    @Override
    public void batchInsertDetailInfo(List<dBlOrderDtOnline> details) {
        detailMapper.batchInsertDetailInfo(details);
    }

    /**
     * 根据订单编号获取订单明细信息
     *
     * @param orderId
     * @return
     */
    @Override
    public List<dBlOrderDtOnline> getAllOrderDetailByOrderId(String orderId) {
        return detailMapper.getAllOrderDetailByOrderId(orderId);
    }


    /**
     * 根据订单编号获取订单信息
     * 获取到的都是导入的订单信息
     *
     * @param orderId
     * @return
     */
    @Override
    public List<dBlOrderDtOnline> getAllImportOrderInfosByOrderId(String orderId) {
        return detailMapper.getAllImportOrderInfosByOrderId(orderId);
    }

    /**
     * 根据订单编号和商品编号删除商品明细信息
     *
     * @param orderId
     * @param itemId
     * @return
     */
    @Override
    public int deleteOrderDetailByOrderIdAndItemId(String orderId, String itemId) {
        return detailMapper.deleteOrderDetailByItemIdAndOrderId(orderId, itemId);
    }

    /**
     * 根据订单编码以及商品编号逻辑删除明细信息
     *
     * @param orderId
     * @param itemId
     * @return
     */
    @Override
    public int updateOrderDetailByItemIdAndOrderId(String orderId, String itemId) {
        return detailMapper.updateOrderDetailByItemIdAndOrderId(orderId, itemId);
    }

    /**
     * 根据订单编号以及商品编号逻辑删除导入的订单信息
     *
     * @param orderId
     * @param itemId
     * @return
     */
    @Override
    public int updateImportOrderDetailByItemIdAndOrderId(String orderId, String itemId) {
        return detailMapper.updateImportOrderDetailByItemIdAndOrderId(orderId, itemId);
    }

    /**
     * 根据制单人编号/名称获取当前该制单人下所有订单明细信息
     *
     * @param createStaffId
     * @return
     */
    @Override
    public List<dBlOrderDtOnline> getAllOrderDetailInfoByCreateStaff(String createStaffId) {
        return detailMapper.getAllOrderDetailInfoByCreateStaff(createStaffId);
    }

    /**
     * 根据客户名称和订单编号获取当前订单下所有的订单明细信息
     *
     * @param createStaffId
     * @param orderId
     * @return
     */
    @Override
    public List<dBlOrderDtOnline> getAllOrderDetailInfoByCreateStaffAndOrderId(String createStaffId, String orderId) {
        return detailMapper.getAllOrderDetailInfoByCreateStaffAndOrderId(createStaffId, orderId);
    }


    /**
     * 根据商品编号以及制单人编号来更新商品的选购数量
     *
     * @param itemId
     * @param createStaffId
     * @param itemOrderNum
     */
    @Override
    public int updateOrderDetailOrderNumber(String itemId, String createStaffId, int itemOrderNum, String orderId) {
        return detailMapper.updateOrderDetailOrderNumber(itemId, createStaffId, itemOrderNum, orderId);
    }

    /**
     * 根据商品编号以及制单人编号和订单编号更新当前商品即将入库货品定量
     *
     * @param itemId
     * @param createStaffId
     * @param jjrkhpdlNumber
     * @param orderId
     * @return
     */
    @Override
    public int updateOrderDetailjjrkhpdl(String itemId, String createStaffId, int jjrkhpdlNumber, String orderId) {
        return detailMapper.updateOrderDetailjjrkhpdl(itemId, createStaffId, jjrkhpdlNumber, orderId);
    }

    /**
     * 根据商品编号以及制单人编号获取商品详情信息
     *
     * @param itemId
     * @param createStaffId
     * @return
     */
    @Override
    public dBlOrderDtOnline getOrderDetailInfoByItemIdAndCreateStaffId(String itemId, String createStaffId, String orderId) {
        return detailMapper.getOrderDetailInfoByItemIdAndCreateStaffId(itemId, createStaffId, orderId);
    }


    /**
     * 根据订单编号删除订单明细信息
     *
     * @param orderId
     * @return
     */
    @Override
    public int deleteOrderInfoDetailByOrderId(String orderId) {
        return detailMapper.deleteOrderInfoDetailByOrderId(orderId);
    }

    /**
     * 根据订单编号逻辑删除订单明细信息
     * 将cancelSign修改为Y
     *
     * @param orderId
     * @return
     */
    @Override
    public int updateOrderDetailByOrderId(String orderId) {
        return detailMapper.updateOrderDetailByOrderId(orderId);
    }


    /**
     * 根据制单人编号获取所有订单明细信息
     *
     * @param createStaff
     * @return
     */
    @Override
    public List<dBlOrderDtOnline> getAllItemOrderDetailByCreateStaffId(String createStaff) {
        return detailMapper.getAllItemOrderDetailByCreateStaffId(createStaff);
    }

    /**
     * 根据订单和客户编号查询该客户下所有的订单明细
     *
     * @param orderId
     * @param createStaffId
     * @return
     */
    @Override
    public List<dBlOrderDtOnline> selectAllOrderDetailByOidAndCreId(String orderId, String createStaffId) {
        return detailMapper.selectAllOrderDetailByOidAndCreId(orderId, createStaffId);
    }

    /**
     * 根据客户编号获取该订单下商品进行分组后的数量与价格
     *
     * @param orderId
     * @return
     */
    @Override
    public List<dBlOrderDtOnlineVo> selectAllOrderGroupBySmClassId(String orderId) {
        return detailMapper.selectAllOrderGroupBySmClassId(orderId);
    }


    /**
     * 根据订单编号以及商品编号 制单人 来更新备注单品订单备注
     *
     * @param createStaffId
     * @param orderId
     * @param itemId
     * @param remark
     * @return
     */
    @Override
    public int updateItemRemarkByCidAndOidAndItemId(String createStaffId, String orderId, String itemId, String remark) {
        return detailMapper.updateItemRemarkByCidAndOidAndItemId(createStaffId, orderId, itemId, remark);
    }
}
